package cn.tedu.basic;

import java.io.*;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;

//测试 写出流 OutputStream 单字节写出
public class Test3_Out {
    public static void main(String[] args) throws IOException {
        Method();
        Method2();
    }
    public static void Method() throws IOException {
        File f =new File("D:\\a\\22.txt");
        OutputStream o1 =new  FileOutputStream(f,true);//追加
        o1.write(99);
        o1.write("98995896578".getBytes());
//        o1.close();
        OutputStream o =new FileOutputStream("D:\\a\\22.txt",true);//追加
        o.write(97);
//        o.close();
    }
    // 高级流写出,实现缓冲的输出流--BufferedOutputStream--底层维护一个byte[]数组，以数组批量写出
    public static void Method2() throws IOException {
        OutputStream fl =new BufferedOutputStream(new FileOutputStream("D:\\a\\22.txt",true));
        fl.write(98);
        fl.write(544);
        fl.write("564844464dsgfdhbh".getBytes());
        fl.close();
    }
}
